﻿<?xml version="1.0" encoding="utf-8" ?>
<Rules FriendlyName="FxCopContrib">
  <Rule TypeName="DoNotUseParseAndToStringToConvertTypes" Category="Performance" CheckId="FxC1801">
    <Name>Do not use Parse and ToString to Convert Types</Name>
    <Description>If a value is being converted from one type to another a loss of precision might occur if the value is first converted to string an then parsed again. For certain types (such as DateTime), round-tripping might not succeed depending on the culture settings. And converting values can often be done in a much faster way than round-tripping through string.</Description>
    <Url>http://fxcopcontrib.codeplex.com/wikipage?title=DoNotUseParseAndToStringToConvertTypes</Url>
    <Resolution>Use Convert.ToXXX or cast directly to the appropriate type.</Resolution>
    <MessageLevel Certainty="100">CriticalWarning</MessageLevel>
    <FixCategories>DependsOnFix</FixCategories>
    <Email>jesse.houwing@gmail.com</Email>
    <Owner>Jesse Houwing</Owner>
  </Rule>


  <Rule TypeName="DoNotIgnoreResultOfImmutableMethods" Category="Usage" CheckId="FxC2201">
    <Name>Ignoring the result of a method on an Immutable Type is usually a bug</Name>
    <Description>When a method on an Immutable Type is called, which in itself also returns an Immutable type, it usually was the intention to overwrite the original value or another local variable.</Description>
    <Url>http://fxcopcontrib.codeplex.com/wikipage?title=DoNotIgnoreResultOfImmutableMethods</Url>
    <Resolution>Ignoring the result of a method on an Immutable Type is usually a bug</Resolution>
    <MessageLevel Certainty="100">Warning</MessageLevel>
    <FixCategories>DependsOnFix</FixCategories>
    <Email>jesse.houwing@gmail.com</Email>
    <Owner>Jesse Houwing</Owner>
  </Rule>


  <Rule TypeName="ConsiderMakingRegexReadOnlyAndCompiled" Category="Performance" CheckId="FxC1802">
    <Name>Consider marking your shared instances of Regx static, readonly and Compiled.</Name>
    <Description>When you pass a string to the constructor or one of the static methods of Regex, the expression will be parsed and if requested compiled. Compilation takes additional time, but will make future use of the same expression faster. If the RegexOptions.Compiled flag is not passed to the constructor or when you're using the static methods the expression will be converted to a state machine. By default only 17 of these state machines are cached.</Description>
    <Url>http://fxcopcontrib.codeplex.com/wikipage?title=ConsiderMakingRegexReadOnlyAndCompiled</Url>
    <Resolution Name="UseRegexOptionsCompiled">To improve the performance of your regular expression, consider using RegexOptions.Compiled.</Resolution>
    <Resolution Name="UseStaticField">To improve the performance of your regular expression, consider marking the field static.</Resolution>
    <Resolution Name="UseReadonlyField">To improve the performance of your regular expression, consider marking the field readonly.</Resolution>
    <MessageLevel Certainty="25">Information</MessageLevel>
    <FixCategories>DependsOnFix</FixCategories>
    <Email>jesse.houwing@gmail.com</Email>
    <Owner>Jesse Houwing</Owner>
  </Rule>

  
  <Rule TypeName="RegularExpressionDoesNotCompile" Category="Usage" CheckId="FxC2202">
    <Name>Your Regular Expression contains errors</Name>
    <Description>Your Regular Expression contains errors</Description>
    <Url>http://fxcopcontrib.codeplex.com/wikipage?title=RegularExpressionDoesNotCompile</Url>
    <Resolution Name="InvalidRegexOptions">Invalid bitwise combination of RegexOptions. RegexOptions.ECMAScript can only combined with RegexOptions.Multiline, RegexOptions.IgnoreCase and RegexOptions.Compiled</Resolution>
    <Resolution Name="UnknownRegexOptions">An unknown RegexOption was passed to a Regex. The unrecognised value is: {1}</Resolution>
    <Resolution Name="InvalidRegex">The string '{0}' used as Regular Expression contains an error. The error is: {1}</Resolution>
    <MessageLevel Certainty="100">CriticalError</MessageLevel>
    <FixCategories>DependsOnFix</FixCategories>
    <Email>jesse.houwing@gmail.com</Email>
    <Owner>Jesse Houwing</Owner>
  </Rule>

  <Rule TypeName="RefererenceLocalStructCorrectlyInClosure" Category="Usage" CheckId="FxC2203">
    <Name>Refererence Local Struct Correctly In Closure</Name>
    <Description>If a struct is referenced in a Closure and is also assigned to after it is passed to the Closure, it will actually be referenced by reference and not by value as many might expect.</Description>
    <Url>http://fxcopcontrib.codeplex.com/wikipage?title=RefererenceLocalStructCorrectlyInClosure</Url>
    <Resolution>To fix this violation either assign the value to a different local struct variable or use a method signature that allows you to pass in the variable outside of the closure.</Resolution>
    <MessageLevel Certainty="100">CriticalError</MessageLevel>
    <FixCategories>DependsOnFix</FixCategories>
    <Email>jesse.houwing@gmail.com</Email>
    <Owner>Jesse Houwing</Owner>
  </Rule>
</Rules>
